
def jwt_response_payload_handler(token, user=None, request=None):
    '''

    :param token: 认证后，系统生成的token
    :param user:  认证后的用户
    :param request: 登陆认证的请求
    :return:
    '''
    return {
        'token': token,
        'username': user.username,
        'id':user.id
    }

from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
class PageNum(PageNumberPagination):
    #自定义分页
    page_size=5
    page_size_query_param = 'pagesize'  #此时postman可使用pagesize
    max_page_size = 20

    def get_paginated_response(self, data):
        return Response({
            'count': self.page.paginator.count,
            'lists':data,             #序列化后的列表数据，原来的data
            "page":self.page.number,  #当前页
            "pages":self.page.paginator.num_pages,  #总页数
            "pagesize":self.page_size

            })
        # return Response(OrderedDict([
        #     ('count', self.page.paginator.count),
        #     ('next', self.get_next_link()),
        #     ('previous', self.get_previous_link()),
        #     ('results', data)
        # ]))